﻿<%@ Page Title="" Language="C#" MasterPageFile="~/WebmasterTool/Admin.Master" AutoEventWireup="true"
    CodeBehind="OrderDetails.aspx.cs" Inherits="Framework.WebmasterTool.Orders.OrderDetails" %>

<%@ Register src="../../Resources/Watermark.ascx" tagname="Watermark" tagprefix="uc2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ctlCaption" runat="Server">
    Chi tiết đơn hàng
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PageContent" runat="Server">
    <asp:Label ID="lblPermissionMessage" runat="server" Font-Bold="true" ForeColor="Red"
        Text="Tài khoản không có quyền truy cập vào trang này" Visible="false"></asp:Label>
    <asp:Panel ID="Panel1" runat="server" Visible="true">
        <table style="border-collapse: separate; border-spacing: 5px; border: 0px; width: 780px;">
            <tr>
                <td colspan="2" style="text-align: center;">
                    <asp:Label ID="lblMsg" runat="server" ForeColor="Red"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <uc2:Watermark ID="Watermark1" runat="server" />
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                    Mã đơn hàng:
                </td>
                <td style="text-align: left;">
                    <asp:Label ID="lblOrderID" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                    User:
                </td>
                <td style="text-align: left;">
                    <asp:Label ID="lblOrderUser" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                    Người đặt hàng:
                </td>
                <td style="text-align: left;">
                    <asp:Label ID="lblOrderReciver" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                    Điện thoại:
                </td>
                <td style="text-align: left;">
                    <asp:Label ID="lblOrderPhone" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                    Địa chỉ:
                </td>
                <td style="text-align: left;">
                    <asp:Label ID="lblOrderAddress" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                    Email:
                </td>
                <td style="text-align: left;">
                    <asp:Label ID="lblOrderEmail" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                    Ngày tạo:
                </td>
                <td style="text-align: left;">
                    <asp:Label ID="lblOrderAddedDate" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                    Ngày hết hạn:
                </td>
                <td style="text-align: left;">
                    <asp:Label ID="lblOderExpired" runat="server"></asp:Label>
                </td>
            </tr>
        </table>
        <p>
            Thông tin đơn hàng:</p>
        <table style="border-collapse: separate; border-spacing: 5px; border: 0px; width: 780px;">
            <tr>
                <td style="text-align: right; width: 120px;">
                    Tình trạng:
                </td>
                <td style="text-align: left;">
                    <asp:DropDownList ID="ddlOrderStatus" runat="server">
                        <asp:ListItem Value="0" Text="Chưa xác nhận"></asp:ListItem>
                        <asp:ListItem Value="1" Text="Đã xác nhận"></asp:ListItem>
                        <asp:ListItem Value="2" Text="Thành công"></asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                    Ngày yêu cầu:
                </td>
                <td style="text-align: left;">
                    <asp:Label ID="lblOrderRequireDate" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                    Tổng tiền:
                </td>
                <td style="text-align: left;">
                    <asp:Label ID="lblOrderAmount" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table class="grid" rules="all" style="border-collapse: collapse; width: 780px;">
                        <thead>
                            <tr>
                                <th scope="col">
                                    Tên sản phẩm
                                </th>
                                <th scope="col">
                                    Giá gốc
                                </th>
                                <th scope="col">
                                    Giá bán
                                </th>
                                <th scope="col">
                                    Giá khuyến mãi
                                </th>
                                <th scope="col">
                                    % khuyến mãi
                                </th>
                                <th scope="col">
                                    Số lượng
                                </th>
                                <th scope="col">
                                    Thành tiền
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <% 
                                foreach (var item in orderDetails)
                                {
                            %>
                            <tr>
                                <td>
                                    <% item.udv_ProductsReference.Load(); %>
                                    <%= item.udv_Products != null ? "<a href='/WebmasterTool/Products/ProductAdd.aspx?ProductID="+ item.udv_Products.ProductID + "'>" +item.udv_Products.Title + "</a>" : "Sản phẩm đã xoá" %>
                                </td>
                                <td style="text-align: right;">
                                    <%= string.Format("{0:0,0}", item.UnitPrice) %>
                                </td>
                                <td style="text-align: right;">
                                    <%= string.Format("{0:0,0}", item.SalePrice)%>
                                </td>
                                <td style="text-align: right;">
                                    <%= string.Format("{0:0,0}", item.PromotionPrice)%>
                                </td>
                                <td style="text-align: right;">
                                    <%= string.Format("{0:0,0}", item.PromotionPercent)%>
                                </td>
                                <td style="text-align: right;">
                                    <%= string.Format("{0:0,0}", item.Quantity)%>
                                </td>
                                <td style="text-align: right;">
                                    <%= string.Format("{0:0,0}", (item.PromotionPrice == null || item.PromotionPrice == 0 ? item.SalePrice : item.PromotionPrice) * item.Quantity)
                                    %>
                                </td>
                            </tr>
                            <%
                                }
                            %>
                            <tr>
                                <td colspan="6">
                                    Tổng giá gốc
                                </td>
                                <td style="text-align: right;">
                                    <%
                                        decimal orderTotalOriginal = 0;
                                        orderDetails.ForEach(od => orderTotalOriginal += (od.UnitPrice.Value * od.Quantity.Value));
                                    %>
                                    <%= string.Format("{0:0,0}", orderTotalOriginal)%>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="6">
                                    Tổng giá bán
                                </td>
                                <td style="text-align: right;">
                                    <% 
                                        decimal orderTotalSale = 0;
                                        orderDetails.ForEach(od => orderTotalSale += (od.PromotionPrice == null || od.PromotionPrice.Value == 0 ? od.SalePrice.Value : od.PromotionPrice.Value) * od.Quantity.Value);
                                    %>
                                    <%= string.Format("{0:0,0}", orderTotalSale)%>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="6">
                                    Tiền lãi
                                </td>
                                <td style="text-align: right;">
                                    <%
                                        decimal orderTotalRate = orderTotalSale - orderTotalOriginal;
                                    %>
                                    <%= string.Format("{0:0,0}", orderTotalRate)%>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                    Yêu cầu thêm:
                </td>
                <td style="text-align: left;">
                    <asp:Label ID="lblOrderDescription" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                    Trả lời:
                </td>
                <td style="text-align: left;">
                    <div style="margin-bottom: 5px">
                        Tiêu đề:
                        <asp:TextBox ID="txtOrderAnswerTitle" runat="server" Width="500"></asp:TextBox><br />
                        Nội dung:
                    </div>
                    <CKEditor:CKEditorControl ID="txtOrderAnswerBody" runat="server" UIColor="#CED9F3"
                        Width="600" Height="200" Toolbar="Full" BasePath="/Plugins/Ckeditor" ContentsCss="/Plugins/Ckeditor/contents.css"
                        TemplatesFiles="/Plugins/Ckeditor/plugins/templates/templates/default.js">
                    </CKEditor:CKEditorControl>
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                    Có
                    <asp:Literal ID="lblCountOrderAnswer" runat="server"></asp:Literal>
                    bài trả lời lưu lại
                </td>
                <td>
                    <a id="aOrderAnswer" runat="server">Xem các bài trả lời trước đây</a>
                </td>
            </tr>
            <tr>
                <td align="right" width="120">
                    Ngày gửi cuối:
                </td>
                <td>
                    <asp:Label ID="lblOrderUpdatedDate" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td align="right" width="120">
                    Người gửi cuối:
                </td>
                <td>
                    <asp:Label ID="lblOrderUpdatedBy" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="text-align: right; width: 120px;">
                </td>
                <td style="text-align: left;">
                    <asp:Button ID="btnBack" runat="server" Text="Quay lại" OnClick="btnBack_Click" />
                    <asp:Button ID="btnSave" runat="server" Text="Lưu" Width="100px" OnClick="btnSave_Click" />
                    <asp:Button ID="btnSaveAndSend" runat="server" Text="Lưu và gửi mail" Width="100px"
                        OnClick="btnSaveAndSend_Click" />
                </td>
            </tr>
        </table>
    </asp:Panel>
</asp:Content>
